const koa = require('koa')
const app = new koa()
const bodyparser = require('koa-bodyparser')
const router = require('koa-router')()
const client = require('./routes/client/index')
const admin = require('./routes/admin/index')
const static = require('koa-static')
const cors = require('koa2-cors')

app.use(cors())
// app.use(async (ctx, next) => {
//   ctx.set('Access-Control-Allow-Origin', '*')
//   await next()
// })
app.use(bodyparser())

app.use(static(__dirname + '/static'))

router.get('/', async ctx => {
  console.log('进入路由')
  ctx.body = 'hello world'
})
router.use('/client', client)
router.use('/admin', admin)

console.log('进入路由')

app.use(router.routes())

app.listen(666, () => {
  console.log()
  console.log('Server is running on port 666wuwuwu!')
})
